import React, { Component } from 'react';
import './bookCatalogList.less';

class BookCatalogList extends Component{

	onSelectChapter = (index) => {
		this.props.onSelectChapter(index);
	}

	render(){
		const { chapterList } = this.props;

		return(
			<div className="bookCatalogList">
				<div className="bookCatalogListTitle">
					目录列表(共{chapterList.length}章)
				</div>
				{
					chapterList && chapterList.length > 0 &&
					chapterList.map((chapter, index) => {
						return(
							<p key={index} onClick={() => this.onSelectChapter(index)}>{chapter.title}</p>
						)
					})
					
				}
			</div>
		)
	}
}

export default BookCatalogList;